package org.kth.dks;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.kth.dks.dks_comm.ConnectionManager;
import org.kth.dks.dks_dht.DKSDHTImpl;

public class DKSTest {

  public DKSTest() {
  }

  public static void main( String args[] ) {
      ConnectionManager cm=null;
      try {
        cm = ConnectionManager.newInstance(4440); // Static factory only used for testing, should use getInstance (singleton)
      } catch(IOException ioex) {
        System.err.println("Port 4440 already taken!\n");
        return;
      }

    URL me = null;
    URL other = null;

    try {
      me = new URL("http", "topaz.imit.kth.se", 4441, "");
    }
    catch (MalformedURLException ex) {
      ex.printStackTrace();
      System.exit(0);
    }

    try {
      other = new URL("http", "topaz.imit.kth.se", 4440, "");
    }
    catch (MalformedURLException ex) {
      ex.printStackTrace();
      System.exit(0);
    }

    try {
      DKSDHTImpl myDKS = new DKSDHTImpl(cm, 1, me);

    //myDKS.join( 0, me, 0, null );
      myDKS.join(0, other);
    } catch (Exception ex) {}
  }
}
